package 机试题16年;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Created by hest0 on 2017/4/20.
 */
public class 挑选镇长2 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int t = Integer.parseInt(br.readLine());

        //输入数据的组数
        while (t-- != 0) {
            String[] s1 = br.readLine().split(" ");
            int n = Integer.parseInt(s1[0]);
            int m = Integer.parseInt(s1[1]);

            //n是所有的可能性，桶
            int[] a = new int[n + 1];
            int[] b = new int[n + 1];

            //读取数据，放入桶中
            for (int i = 0; i < m; i++) {
                String[] s2 = br.readLine().split(" ");
                int idx1 = Integer.parseInt(s2[0]);
                int idx2 = Integer.parseInt(s2[1]);
                if (idx1 == idx2)
                    continue;
                a[idx1]++;
                b[idx2]++;
            }

            //判断符合镇长的条件的人，出度=0，入度=n-1
            int num = 0;
            int idx = 0;
            for (int i = 1; i <= n; i++) {
                if (a[i] == 0 && b[i] == n - 1) {
                    num++;
                    idx = i;
                    break;
                }
            }

            //输出数据
            if (num == 0) {
                System.out.println(0);
                System.out.println();
            } else {
                System.out.println(num);
                System.out.println(idx);
            }

        }
        br.close();
    }
}
